#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
int a[1000000],b[1000000],c[1000000];
vector<int>l[1000000],w[1000000];
void dfs(int x,int f,int v,int g)
{
    for(int i=0;i<l[x].size();i++)
    if(l[x][i]!=f)
    if(!((x==a[g]&&l[x][i]==b[g])||(x==b[g]&&l[x][i]==a[g])))
    dfs(l[x][i],x,min(v,w[x][i]),g),ans+=min(v,w[x][i]);
}
signed main()
{
    freopen("tatooine.in","r",stdin);
    freopen("tatooine.out","w",stdout);
    scanf("%lld",&n);
    for(int i=1;i<n;i++)
    scanf("%lld%lld%lld",&a[i],&b[i],&c[i]),
    l[a[i]].push_back(b[i]),w[a[i]].push_back(c[i]),
    l[b[i]].push_back(a[i]),w[b[i]].push_back(c[i]);
    for(int i=1;i<n;i++)
    {
        ans=0;
        for(int j=1;j<=n;j++)
        dfs(j,0,20,i);
        printf("%lld\n",ans/2);
    }
    return 0;
}